Computer systems display images on display devices. These images may be color images. On occasion, an image including q colors may need to be displayed in a computer system that only supports p colors, where p is less than q. Such a situation may arise, for example, if an image (or an application that displays an image) designed in one computer system that supports q colors is ported to another computer system that only supports p colors (again, where p is less than q). In this situation, the image including q colors must be converted into an image including p colors so that the image can be displayed in the second computer system.
Known methods for converting an image including q colors into an image including p colors (where p is less than q) involve mapping from the q colors to the p colors. Two known methods are the popularity algorithm and the median-cut algorithm. For a more detailed discussion of these known methods, see Computer Graphics, Principles and Practice, pp. 599-600, by James D. Foley, Andries van Dam, Steven K. Feiner, and John F. Hughes (2nd Edition, Addison-Wesley Publishing Company, Inc., 1990).
These known methods for converting an image are satisfactory for a relatively large image. However, when the image is relatively small in size, these methods are not satisfactory. The problems with these methods can be illustrated with an example.
FIG. 1 shows an image, such as a cursor 10 having three (3) colors. The cursor 10 includes a green block 12, a yellow block 14 partially overlaying the green block, and a black border 16 around the visible portions of both blocks. FIG. 2 shows the cursor 10 after it has been converted into another cursor having two (2) colors using the known methods for converting an image discussed above. As can be seen from the figures, the green block remains green, the yellow block remains yellow, and the black border becomes yellow.
If the converted cursor shown in FIG. 2 is never displayed on a yellow background, the problems with the known conversion methods will not be readily apparent. If the converted cursor is, however, displayed on a yellow background (as shown in FIG. 3), the problems with the known methods are immediately apparent. As can be seen from the figure, the yellow block blends with the yellow background and the shape of the cursor becomes distorted.
The problems with the known conversion methods occur because these methods attempt to preserve the predominant colors of the original image. As a result, these methods often sacrifice the contrast of the original image. In an image that is relatively small in size, the preservation of contrast is more important than the preservation of the predominant colors. Therefore, a need exists to convert an original image into another image having fewer colors than the original image while preserving the contrast of the original image.